import { BaseProvider } from './base-provider'
import { QWenProvider } from './qwen-provider'
import { QianfanProvider } from './qianfan-provider'
import { DeepSeakProvider } from './deepseak-provider'
export function createProvider(providerName: string): BaseProvider {
  // 获取配置Store实例

  switch (providerName) {
    case 'qianfan':
      // 从Store获取千帆配置
      // const qianfanConfig = configStore.getConfig('qianfan')
      // if (!qianfanConfig.accessKey || !qianfanConfig.secretKey) {
      //   throw new Error('请先配置千帆密钥')
      // }
      return new QianfanProvider(
        process.env.QIANFAN_ACCESS_KEY as string,
        process.env.QIANFAN_SECRET_KEY as string
      )

    case 'dashscope':
      // 从Store获取通义千问配置
      // const dashscopeConfig = configStore.getConfig('dashscope')
      // if (!dashscopeConfig.apiKey || !dashscopeConfig.baseURL) {
      //   throw new Error('请先配置通义千问密钥')
      // }
      return new QWenProvider(
        process.env.QWEN_API_KEY as string,
        process.env.QWEN_BASE_URL as string
      )
    case 'deepseek':
      // 从Store获取DeepSeek配置
      // const deepseekConfig = configStore.getConfig('deepseek')
      // if (!deepseekConfig.apiKey || !deepseekConfig.baseURL) {
      //   throw new Error('请先配置DeepSeek密钥')
      // }
      return new DeepSeakProvider(
        process.env.DEEPSEAK_BASE_URL as string,
        process.env.DEEPSEAK_API_KEY as string
      )

    default:
      throw new Error('Invalid provider name')
  }
}
